﻿using System;
using System.Collections.Generic;
using System.Xml.Serialization;

namespace LdtJudge.DataEngine.Model.XMLConfigModel.DataStores
{
    [Serializable]
    [XmlRootAttribute("root", IsNullable = false)]
    public class DataSoursModel 
    {
        /// <summary>
        /// 节点集合
        /// </summary>
        [XmlElementAttribute("DataModel", IsNullable = false)]
        public List<DataModel> dataModelList { get; set; }
    
    }

    /// <summary>
    /// 数据来源内容
    /// </summary>
    [XmlRootAttribute("DataModel", IsNullable = false)]
    public class DataModel : IEqualityComparer<DataModel>
    {
        /// <summary>
        /// 节点唯一标识
        /// </summary>
        [XmlAttribute("id")]
        public string ID { get; set; }

        /// <summary>
        /// 要素节点
        /// </summary>
        [XmlAttribute("XmlPath")]
        public string XmlPath { get; set; }

        /// <summary>
        /// 名称
        /// </summary>
        [XmlAttribute("Name")]
        public string Name { get; set; }

        /// <summary>
        /// 上级ID
        /// </summary>
        [XmlAttribute("ParentId")]
        public string ParentId { get; set; }

        /// <summary>
        /// 状态
        /// </summary>
        [XmlAttribute("State")]
        public string State { get; set; }

        /// <summary>
        /// 案由节点类型
        /// </summary>
        public string CauseType { get; set; }
        /// <summary>
        /// 优先级
        /// </summary>
        [XmlAttribute("Priority")]
        public string Priority { get; set; }



        /// <summary>
        /// 属性集合
        /// </summary>
        [XmlElementAttribute("Attribute", IsNullable = false)]
        public List<AttributeInfo> AttributesList { get; set; }

        /// <summary>
        /// 属性节点
        /// </summary>
        [XmlElementAttribute("SourceData", IsNullable = false)]
        public SourceData sourceData { get; set; }

        public bool Equals(DataModel x, DataModel y)
        {
            if (x == null || y == null)
                return false;
            if (x.ID == y.ID && x.XmlPath == y.XmlPath)
                return true;
            else
                return false;
        }

        public int GetHashCode(DataModel obj)
        {
            if (obj == null)
                return 0;
            else
                return obj.ID.GetHashCode();
        }
    }
    /// <summary>
    /// 属性值
    /// </summary>
    [XmlRootAttribute("Attribute", IsNullable = false)]
    public class AttributeInfo 
    {
        /// <summary>
        /// 名称
        /// </summary>
        [XmlAttribute("Name")]
        public string Name { get; set; }

        /// <summary>
        /// 转字典状态
        /// </summary>
        [XmlAttribute("DictionariesCode")]
        public string DictionariesCode { get; set; }

        /// <summary>
        /// 优先级
        /// </summary>
        [XmlAttribute("Priority")]
        public string Priority { get; set; }

        /// <summary>
        /// 数据源集合
        /// </summary>
        [XmlElementAttribute("Source", IsNullable = false)]
        public List<Source> sourceList { get; set; }

    }

    /// <summary>
    /// 数据来源
    /// </summary>
    [XmlRootAttribute("Source", IsNullable = false)]
    public class Source 
    {
        /// <summary>
        /// 数据来源
        /// </summary>
        [XmlAttribute("SourceCode")]
        public string SourceCode { get; set; }

        /// <summary>
        /// 数据来源ID
        /// </summary>
        [XmlAttribute("SourceID")]
        public string SourceID { get; set; }

        /// <summary>
        /// 数据来源FLID
        /// </summary>
        [XmlAttribute("SourceFLID")]
        public string SourceFLID { get; set; }


        [XmlAttribute("SourceName")]
        public string SourceName { get; set; }
        /// <summary>
        /// 是否选中
        /// </summary>
        [XmlAttribute("IsCheck")]
        public string IsCheck { get; set; }

        /// <summary>
        /// 存储值
        /// </summary>
        [XmlAttribute("SaveValue")]
        public string SaveValue { get; set; }

        /// <summary>
        /// 提取值
        /// </summary>
        [XmlAttribute("ExtValue")]
        public string ExtValue { get; set; }

        /// <summary>
        /// 原文值
        /// </summary>
        [XmlAttribute("OriginalText")]
        public string OriginalText { get; set; }

        /// <summary>
        /// 段落编号
        /// </summary>
        [XmlAttribute("ParagraphCode")]
        public string ParagraphCode { get; set; }

        /// <summary>
        /// 原文定位
        /// </summary>
        [XmlAttribute("OriginalLocation")]
        public string OriginalLocation { get; set; }

        /// <summary>
        /// 原文定位长度
        /// </summary>
        [XmlAttribute("OriginalLocationLen")]
        public string OriginalLocationLen { get; set; }

        /// <summary>
        /// 全文定位
        /// </summary>
        [XmlAttribute("Location")]
        public string Location { get; set; }
        [XmlAttribute("ConvertCode")]
        public string ConvertCode { get; set; }

        //TODO:ZSW 证据与事实要素关系建立
        /// <summary>
        /// 来源节点Id
        /// </summary>
        public string SourceNodeId { get; set; }

        public string zuisu { get; set; }

        public string type { get; set; }

        /// <summary>
        /// 分析状态
        /// </summary>
        [XmlAttribute("AnalysisStatus")]
        public string AnalysisStatus { get; set; }
    }

    /// <summary>
    /// 节点属性
    /// </summary>
    [XmlRootAttribute("SourceData", IsNullable = false)]
    public class SourceData 
    {
        /// <summary>
        /// 过程数据集
        /// </summary>
        [XmlElementAttribute("Source", IsNullable = false)]
        public List<Source> sourceList { get; set; }
    }
}
